﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using Trul.WebUI.Infrastructure;

namespace Trul.WebUI.Controllers
{
    public class ErrorController : BaseController
    {
        [AllowAnonymous()]
        public ActionResult HttpError() {
            var exception = (Exception)HttpContext.Application[Request.UserHostAddress.ToString()];
            if(exception == null) exception = new Exception("Sorry, an error occured while processing your request");
            var exceptionCode = new HttpException(null, exception).GetHttpCode();

            return View(exception);
        }

        [AllowAnonymous()]
        public ActionResult AccessDenied() {
            return View();
        }

        [AllowAnonymous()]
        public ActionResult Http404() {
            throw new HttpException(404, "Page not found");
        }
    }
}
